﻿using Microsoft.EntityFrameworkCore;

namespace EntityModels
{
    public class QueryFilterEntity
    {
        public int Id { get; set; }
        public string Text { get; set; }
        public bool IsDeleted { get; set; }

    }

    /// <summary>
    /// 全局查询过滤器
    /// </summary>
    public class QueryFilterDbContext : DbContext
    {
        public DbSet<QueryFilterEntity> queryFilterEntities => Set<QueryFilterEntity>();

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<QueryFilterEntity>(
                b =>
                {
                    b.HasQueryFilter(q => q.IsDeleted == false);
                });
        }

    }
}
